<% @doc[:resources].sort_by(&:first).each do |key, resource| %>
  <h4><a href='#<%= key %>'><%= resource[:name] %></a></h4>
  <ul>
    <% resource[:methods].each do |method| %>
      <% if !method[:show] %>
        <% next %>
      <% end %>
      <li><a href='#<%= key %>-<%= method[:name] %>'><%= method[:name] %></a></li>
    <% end %>
  </ul>
<% end %>



<div><%= @doc[:info].html_safe %></div>

<hr>

<% @doc[:resources].sort_by(&:first).each do |key, resource| %>

  <ul class='breadcrumb'  id='<%= key %>'>
    <li><a href='#'><%= @doc[:name] %></a><span class='divider'>/</span></li>
    <li class='active'><%= resource[:name] %></li>
  </ul>

  <div class='page-header'>
    <h1>
      <a href='#<%= key %>'><%= resource[:name] %></a><br>
      <small><%= raw resource[:short_description] %></small>
    </h1>
  </div>

  <% unless resource[:full_description].blank? %>
    <div><%= raw resource[:full_description] %></div>
  <% end %>

  <div class='accordion' id='accordion'>

    <% resource[:methods].each do |method| %>
      <% if !method[:show] %>
        <% next %>
      <% end %>
      <hr>

      <ul class='breadcrumb' id='<%= key %>-<%= method[:name] %>'>
        <li>
          <a href='#'><%= @doc[:name] %></a>
          <span class='divider'>/</span>
        </li>
        <li>
          <a href='#<%= key %>'><%= resource[:name] %></a>
          <span class='divider'>/</span>
        </li>
        <li class='active'><%= method[:name] %></li>
      </ul>

      <div>
        <% method[:apis].each do |api| %>
          <h3>
            <a href='#<%= key %>-<%= method[:name] %>'>
              <%= api[:http_method] %> <%= api[:api_url] %>
            </a><br>
            <small><%= raw api[:short_description] %></small>
          </h3>
        <% end %>
      </div>

      <div>
        <%= raw method[:full_description] %>
        <% unless method[:examples].blank? %>
          <h2><%= t('apipie.examples') %></h2>
          <% method[:examples].each do |example| %>
            <pre><%= example %></pre>
          <% end %>
        <% end %>

        <% unless method[:errors].blank? %>
          <h2><%= t('apipie.errors') %></h2>
          <%= render(:partial => "errors", :locals => {:errors => method[:errors]}) %>
        <% end %>

        <% unless method[:params].blank? %>
          <h2><%= t('apipie.params') %></h2>
          <table class='table'>
            <thead>
              <tr>
                <th><%= t('apipie.param_name') %></th>
                <th><%= t('apipie.description') %></th>
              </tr>
            </thead>
            <tbody>
              <%= render(:partial => "params", :locals => {:params => method[:params]}) %>
            </tbody>
          </table>
        <% end %>
      </div>
    <% end %>
  </div>
<% end %>

<% unless content_for(:apipie_footer) == @doc[:copyright] %>
  <%= content_for :apipie_footer, raw(@doc[:copyright]) %>
<% end %>
